package ru.fadeev.crammer;

import java.sql.SQLException;

import javax.swing.JOptionPane;
import javax.swing.UIManager;

import com.jgoodies.looks.LookUtils;
import com.jgoodies.looks.plastic.Plastic3DLookAndFeel;
import com.jgoodies.looks.windows.WindowsLookAndFeel;

import ru.fadeev.crammer.ui.window.CrammerMainFrame;


/**
 * Crammer class represents main class of Crammer program. 
 * It launches Crammer Main Frame. 
 * @author Konstantin Fadeyev
 *
 */
public class Crammer {
    public static void main(String[] args) {
    	
    	try {		
    		if(LookUtils.IS_OS_WINDOWS) {
    			UIManager.setLookAndFeel(new WindowsLookAndFeel());
    		} else {
    			UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
    		}
    		
    		CrammerMainFrame s = new CrammerMainFrame();
    		s.init();
    	} catch(SQLException e) {
            JOptionPane.showMessageDialog(null, "Failed to initialize crammer. " +
            		"The program will exit. \n" +
            		"Make sure that crammer isn't already started. ", 
            		"Error", JOptionPane.ERROR_MESSAGE);
    	} catch(Exception e) {
    		e.printStackTrace();
    	}
	}
}
